home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12137 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  807 b 

  1. Path: bcarh8ab.bnr.ca!liyu
  2. From: liyu@bnr.ca (whyme)
  3. Newsgroups: comp.lang.c++
  4. Subject: what getline returns? Nobody can explain this!!
  5. Date: 16 Mar 1996 21:25:28 GMT
  6. Organization: Bell-Northern Research Canada
  7. Distribution: na
  8. Message-ID: <4ifbk8$6nf@bcarh8ab.bnr.ca>
  9. NNTP-Posting-Host: bcarsfb3.bnr.ca
  10.  
  11. getline member fuction in ifstream is supposed to return the
  12. receiving object (that is, ostream&). 
  13.  
  14. However, many books contain the code samples like:
  15.  
  16. ifstream in("tmp.txt");
  17. while (in.getline(buffer,sizeof(buffer))) { ...  }
  18.  
  19. This loop quits only if in.getline returns 0 or NUll;
  20.                 ^^^^^^^
  21.  
  22. but an ostream object is neither 0 nor NULL;
  23. the result is an object, not integer or pointer.
  24.  
  25. So how can this loop quit?
  26.  
  27. It works; but no one I know can explain this!!!!
  28. Thanks for your help.
  29.